{% extends 'warehouse/base.html' %}

{% block title %}创建商品{% endblock %}

{% block content %}
<div class="row">
    <div class="col-md-12">
        <h1>创建新商品</h1>
        
        {% if messages %}
            {% for message in messages %}
                <div class="alert alert-{{ message.tags }} alert-dismissible fade show" role="alert">
                    {{ message }}
                    <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
                </div>
            {% endfor %}
        {% endif %}
        
        <div class="card">
            <div class="card-header">
                <h3>商品信息</h3>
            </div>
            <div class="card-body">
                <form method="post">
                    {% csrf_token %}
                    <div class="mb-3">
                        <label for="{{ form.name.id_for_label }}" class="form-label">{{ form.name.label }}</label>
                        {{ form.name }}
                        {% if form.name.help_text %}
                            <div class="form-text">{{ form.name.help_text }}</div>
                        {% endif %}
                        {% if form.name.errors %}
                            <div class="alert alert-danger mt-2">{{ form.name.errors }}</div>
                        {% endif %}
                    </div>
                    
                    <div class="mb-3">
                        <label for="{{ form.specification.id_for_label }}" class="form-label">{{ form.specification.label }}</label>
                        {{ form.specification }}
                        {% if form.specification.help_text %}
                            <div class="form-text">{{ form.specification.help_text }}</div>
                        {% endif %}
                        {% if form.specification.errors %}
                            <div class="alert alert-danger mt-2">{{ form.specification.errors }}</div>
                        {% endif %}
                    </div>
                    
                    <div class="mb-3">
                        <label for="{{ form.unit.id_for_label }}" class="form-label">{{ form.unit.label }}</label>
                        {{ form.unit }}
                        {% if form.unit.help_text %}
                            <div class="form-text">{{ form.unit.help_text }}</div>
                        {% endif %}
                        {% if form.unit.errors %}
                            <div class="alert alert-danger mt-2">{{ form.unit.errors }}</div>
                        {% endif %}
                    </div>
                    
                    <div class="mb-3">
                        <label for="{{ form.shelf_life.id_for_label }}" class="form-label">{{ form.shelf_life.label }}</label>
                        {{ form.shelf_life }}
                        {% if form.shelf_life.help_text %}
                            <div class="form-text">{{ form.shelf_life.help_text }}</div>
                        {% endif %}
                        {% if form.shelf_life.errors %}
                            <div class="alert alert-danger mt-2">{{ form.shelf_life.errors }}</div>
                        {% endif %}
                    </div>
                    
                    <div class="mb-3">
                        <label for="{{ form.min_stock.id_for_label }}" class="form-label">{{ form.min_stock.label }}</label>
                        {{ form.min_stock }}
                        {% if form.min_stock.help_text %}
                            <div class="form-text">{{ form.min_stock.help_text }}</div>
                        {% endif %}
                        {% if form.min_stock.errors %}
                            <div class="alert alert-danger mt-2">{{ form.min_stock.errors }}</div>
                        {% endif %}
                    </div>
                    
                    <div class="mb-3">
                        <label for="{{ form.max_stock.id_for_label }}" class="form-label">{{ form.max_stock.label }}</label>
                        {{ form.max_stock }}
                        {% if form.max_stock.help_text %}
                            <div class="form-text">{{ form.max_stock.help_text }}</div>
                        {% endif %}
                        {% if form.max_stock.errors %}
                            <div class="alert alert-danger mt-2">{{ form.max_stock.errors }}</div>
                        {% endif %}
                    </div>
                    
                    <button type="submit" class="btn btn-primary">创建商品</button>
                    <a href="{% url 'warehouse:goods_list' %}" class="btn btn-secondary">取消</a>
                </form>
            </div>
        </div>
        
        <div class="mt-3">
            <a href="{% url 'warehouse:dashboard' %}" class="btn btn-secondary">返回仪表盘</a>
        </div>
    </div>
</div>
{% endblock %}